/**
 *  @file highScoreModel.h
 *
 *  @date 22-dec-2009
 *  @author Ives van der Flaas
 */

#ifndef HIGHSCOREMODEL_H_
#define HIGHSCOREMODEL_H_

#include <vector>
#include <utility>
#include <algorithm>
#include <string>
namespace si
{
/**
 * Model for highscores. Will load from an xml file,
 * store to another xml file.
 */
class HighScoreModel
{
public:
	HighScoreModel();
	virtual ~HighScoreModel();

	/**
	 * Loads from XML file
	 */
	void load();

	/**
	 * Stores to XML file
	 */
	void save();

	/**
	 * Returns true if score is high enough to be in the highscores.
	 * @param score
	 * @return
	 */
	bool canBeInHighScores(int score);

	/**
	 * Adds a new couple to the model.
	 * @param name Name of the person to be added
	 * @param score Score of the person to be added
	 */
	void addEntry(std::string name, int score);

	/**
	 * Returns the top 10 highscores (or less).
	 * @return
	 */
	std::pair<std::vector<std::string>, std::vector<int> > getVectors() const;

private:
	std::vector<std::pair<std::string, int > > fHighScores;
};

/**
 * The maximum number of highscores at one time in
 * the model. More than this and the one with lowest
 * score is discarted.
 */
const unsigned int nrOfHighScores = 10;
}

#endif /* HIGHSCOREMODEL_H_ */
